﻿
using SuperSocket.ClientEngine;
using System;
using System.Net;

namespace Robot
{
    public class Program
    {
        private static AsyncTcpSession client;
        static void Main(string[] args)
        {
            client = new AsyncTcpSession();
            // 连接断开事件
            client.Closed += Closed;
            // 收到服务器数据事件
            client.DataReceived += DataReceived;
            // 连接到服务器事件
            client.Connected += Connected;
            // 发生错误的处理
            client.Error += Error;

            client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6650));

            Console.ReadLine();
        }

        private static void Connected(object sender, EventArgs e)
        {
            Console.WriteLine("连接成功");
        }

        private static void DataReceived(object sender, DataEventArgs e)
        {
            Console.WriteLine("收到消息"); 
        }

        private static void Error(object sender, ErrorEventArgs e)
        {
            Console.WriteLine("连接出错：" + e.ToString()); 
        }

        private static void Closed(object sender, EventArgs e)
        {
            Console.WriteLine("连接关闭：" + e.ToString());
        }
    }
}
